<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>数据字典 | d2-crud-plus</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="icon" href="/d2-crud-plus/icon-only.png">
    <link rel="manifest" href="/d2-crud-plus/manifest.json">
    <link rel="apple-touch-icon" href="/d2-crud-plus/icons/apple-touch-icon-152x152.png">
    <link rel="mask-icon" href="/d2-crud-plus/icons/safari-pinned-tab.svg" color="#3eaf7c">
    <meta name="description" content="d2-crud-plus doc">
    <meta name="theme-color" content="#3eaf7c">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="msapplication-TileImage" content="/icons/msapplication-icon-144x144.png">
    <meta name="msapplication-TileColor" content="#000000">
    
    <link rel="preload" href="/d2-crud-plus/assets/css/0.styles.04fdeb33.css" as="style"><link rel="preload" href="/d2-crud-plus/assets/js/app.cf559687.js" as="script"><link rel="preload" href="/d2-crud-plus/assets/js/2.40e3d83c.js" as="script"><link rel="preload" href="/d2-crud-plus/assets/js/7.20165752.js" as="script"><link rel="preload" href="/d2-crud-plus/assets/js/73.4c7255c5.js" as="script"><link rel="prefetch" href="/d2-crud-plus/assets/js/10.df64ceb4.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/100.1b960036.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/101.0e6b7c65.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/102.60335619.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/11.d9cc7359.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/12.1fe853d9.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/13.beccd8a2.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/14.a22b7450.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/15.bfbc8e57.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/16.829da345.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/17.320c2a84.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/18.1ae2555c.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/19.dd1cfb7c.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/20.9f88070e.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/21.b4e311e8.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/22.508bfd88.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/23.d99910ba.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/24.3aac1d86.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/25.7f84d66c.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/26.010188d3.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/27.7ffcde1a.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/28.e5718534.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/29.a664aead.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/3.020e8c98.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/30.b5af54a5.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/31.3ce7cf81.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/32.74db3cbf.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/33.4afafef0.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/34.802ed380.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/35.829671b1.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/36.d62ff643.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/37.56355919.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/38.ef3567a6.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/39.f5bd440b.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/4.c9f444e5.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/40.097677b2.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/41.a1bdd4d7.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/42.d7c95839.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/43.ff1defe3.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/44.d08c49cd.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/45.15500c6e.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/46.49432e0a.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/47.4c86a170.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/48.9fb26f3b.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/49.2f1d3b4c.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/5.0c166f17.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/50.8adcf1fc.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/51.9debc188.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/52.b337fe05.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/53.1b4c4595.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/54.60ad5592.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/55.1ead7a60.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/56.4b4068b5.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/57.39b9a334.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/58.e342a69f.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/59.9286ee5c.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/6.dc3cf8b6.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/60.fca56e66.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/61.e53daf76.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/62.afa730c3.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/63.515344c7.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/64.5ea21d7e.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/65.5736928f.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/66.354c4f97.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/67.e458985d.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/68.9cf2e48e.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/69.afff9087.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/70.5f510366.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/71.08e285c9.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/72.fbdbf96d.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/74.dbca5940.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/75.3cdd0828.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/76.cdad6b31.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/77.f79386ae.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/78.885784bf.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/79.90e30120.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/8.ce580690.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/80.2b6522e0.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/81.ab19ef97.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/82.cb46f8f4.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/83.67a48600.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/84.224a00c3.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/85.e4002b19.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/86.e1acfe7c.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/87.263718a8.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/88.4548fddc.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/89.dcd81e26.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/9.18394d2c.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/90.70193895.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/91.60784f38.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/92.82037907.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/93.f7bbaf29.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/94.bfb96693.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/95.27670bd5.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/96.068d6ad1.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/97.d82da56e.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/98.20649291.js"><link rel="prefetch" href="/d2-crud-plus/assets/js/99.74bab3f4.js">
    <link rel="stylesheet" href="/d2-crud-plus/assets/css/0.styles.04fdeb33.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/d2-crud-plus/" class="home-link router-link-active"><!----> <span class="site-name">d2-crud-plus</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/d2-crud-plus/guide/" class="nav-link router-link-active">
  指南
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="更多" class="dropdown-title"><span class="title">更多</span> <span class="arrow down"></span></button> <button type="button" aria-label="更多" class="mobile-dropdown-title"><span class="title">更多</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>
          核心
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/d2-crud-plus/d2-crud-x/" class="nav-link">
  D2-CRUD-X
</a></li></ul></li><li class="dropdown-item"><h4>
          周边项目
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://gitee.com/greper/d2-crud-plus" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Gitee镜像
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://github.com/greper/d2-crud-plus-with-d2admin-starter" target="_blank" rel="noopener noreferrer" class="nav-link external">
  精简启动项目
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://gitee.com/greper/d2-crud-plus-with-d2admin-starter" target="_blank" rel="noopener noreferrer" class="nav-link external">
  精简启动项目[gitee]
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://github.com/greper/d2-crud-plus-with-d2admin-starter/tree/permission" target="_blank" rel="noopener noreferrer" class="nav-link external">
  精简启动项目-带权限
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://gitee.com/greper/d2-crud-plus-with-d2admin-starter/tree/permission" target="_blank" rel="noopener noreferrer" class="nav-link external">
  精简启动项目-带权限[gitee]
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://github.com/greper/d2-crud-plus-server" target="_blank" rel="noopener noreferrer" class="nav-link external">
  配套java后端
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://gitee.com/greper/d2-crud-plus-server" target="_blank" rel="noopener noreferrer" class="nav-link external">
  配套java后端[gitee]
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>
          附加
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/d2-crud-plus/guide/permission.html" class="nav-link">
  权限管理
</a></li><li class="dropdown-subitem"><a href="/d2-crud-plus/guide/generate.html" class="nav-link">
  代码生成
</a></li></ul></li><li class="dropdown-item"><h4>
          衍生项目
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://cloud.battcn.com/#/index" target="_blank" rel="noopener noreferrer" class="nav-link external">
  后台获取配置的CRUD
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>
          友情链接
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://gitee.com/docmirror/dev-sidecar" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Github加速工具
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li></ul></div></div><div class="nav-item"><a href="http://preview.d2-crud-plus.docmirror.cn/D2CrudPlusExample/index.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  演示
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/greper/d2-crud-plus" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/d2-crud-plus/guide/" class="nav-link router-link-active">
  指南
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="更多" class="dropdown-title"><span class="title">更多</span> <span class="arrow down"></span></button> <button type="button" aria-label="更多" class="mobile-dropdown-title"><span class="title">更多</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>
          核心
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/d2-crud-plus/d2-crud-x/" class="nav-link">
  D2-CRUD-X
</a></li></ul></li><li class="dropdown-item"><h4>
          周边项目
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://gitee.com/greper/d2-crud-plus" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Gitee镜像
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://github.com/greper/d2-crud-plus-with-d2admin-starter" target="_blank" rel="noopener noreferrer" class="nav-link external">
  精简启动项目
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://gitee.com/greper/d2-crud-plus-with-d2admin-starter" target="_blank" rel="noopener noreferrer" class="nav-link external">
  精简启动项目[gitee]
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://github.com/greper/d2-crud-plus-with-d2admin-starter/tree/permission" target="_blank" rel="noopener noreferrer" class="nav-link external">
  精简启动项目-带权限
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://gitee.com/greper/d2-crud-plus-with-d2admin-starter/tree/permission" target="_blank" rel="noopener noreferrer" class="nav-link external">
  精简启动项目-带权限[gitee]
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://github.com/greper/d2-crud-plus-server" target="_blank" rel="noopener noreferrer" class="nav-link external">
  配套java后端
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://gitee.com/greper/d2-crud-plus-server" target="_blank" rel="noopener noreferrer" class="nav-link external">
  配套java后端[gitee]
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>
          附加
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/d2-crud-plus/guide/permission.html" class="nav-link">
  权限管理
</a></li><li class="dropdown-subitem"><a href="/d2-crud-plus/guide/generate.html" class="nav-link">
  代码生成
</a></li></ul></li><li class="dropdown-item"><h4>
          衍生项目
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://cloud.battcn.com/#/index" target="_blank" rel="noopener noreferrer" class="nav-link external">
  后台获取配置的CRUD
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>
          友情链接
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://gitee.com/docmirror/dev-sidecar" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Github加速工具
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li></ul></div></div><div class="nav-item"><a href="http://preview.d2-crud-plus.docmirror.cn/D2CrudPlusExample/index.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  演示
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/greper/d2-crud-plus" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <div style="padding:20px 30px  0px 30px;"><a target="_blank" href="https://www.aliyun.com/minisite/goods?userCode=qya11txb" style="width:100%"><img src="https://img.alicdn.com/tfs/TB1qnR3R1L2gK0jSZFmXXc7iXXa-440-240.jpg" style="width:100%"></a></div> <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>指南</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/" aria-current="page" class="sidebar-link">介绍</a></li><li><a href="/d2-crud-plus/guide/quickstart.html" class="sidebar-link">快速上手</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>进阶</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/mixins.html" class="sidebar-link">核心逻辑</a></li><li><a href="/d2-crud-plus/guide/structure.html" class="sidebar-link">数据结构</a></li><li><a href="/d2-crud-plus/guide/column-type.html" class="sidebar-link">字段类型</a></li><li><a href="/d2-crud-plus/guide/types.html" class="sidebar-link">字段类型列表</a></li><li><a href="/d2-crud-plus/guide/custom-type.html" class="sidebar-link">自定义字段类型</a></li><li><a href="/d2-crud-plus/guide/component.html" class="sidebar-link">组件配置</a></li><li><a href="/d2-crud-plus/guide/slot.html" class="sidebar-link">slot自定义</a></li><li><a href="/d2-crud-plus/guide/extends.html" class="sidebar-link">自定义扩展</a></li><li><a href="/d2-crud-plus/guide/dict.html" aria-current="page" class="active sidebar-link">数据字典</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/dict.html#字典配置复制" class="sidebar-link">字典配置复制</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/dict.html#数据字典的配置" class="sidebar-link">数据字典的配置</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/dict.html#页面中获取数据字典" class="sidebar-link">页面中获取数据字典</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/dict.html#清除字典缓存" class="sidebar-link">清除字典缓存</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/dict.html#onready事件监听" class="sidebar-link">onReady事件监听</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/dict.html#如何设置行展示组件【values-format】的颜色" class="sidebar-link">如何设置行展示组件【values-format】的颜色</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/dict.html#动态修改字典数据" class="sidebar-link">动态修改字典数据</a></li><li class="sidebar-sub-header"><a href="/d2-crud-plus/guide/dict.html#字典缓存仅页面级别生效" class="sidebar-link">字典缓存仅页面级别生效</a></li></ul></li><li><a href="/d2-crud-plus/guide/nest-data.html" class="sidebar-link">多级数据</a></li><li><a href="/d2-crud-plus/guide/flat-data.html" class="sidebar-link">数据扁平化</a></li><li><a href="/d2-crud-plus/guide/data-export.html" class="sidebar-link">数据导出</a></li><li><a href="/d2-crud-plus/guide/line-edit.html" class="sidebar-link">行编辑</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>API</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/options.html" class="sidebar-link">crud配置项</a></li><li><a href="/d2-crud-plus/guide/expose.html" class="sidebar-link">暴露的方法</a></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>扩展</span> <span class="arrow right"></span></p> <!----></section></li><li><section class="sidebar-group collapsable is-sub-group depth-1"><p class="sidebar-heading"><span>组件</span> <span class="arrow right"></span></p> <!----></section></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>附加功能</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/permission.html" class="sidebar-link">权限管理</a></li><li><a href="/d2-crud-plus/guide/generate.html" class="sidebar-link">代码生成</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>更多帮助</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/upgrade.html" class="sidebar-link">版本升级</a></li><li><a href="/d2-crud-plus/guide/breakingchange.html" class="sidebar-link">破坏性变更</a></li><li><a href="/d2-crud-plus/guide/upgradechange.html" class="sidebar-link">版本变更说明</a></li><li><a href="/d2-crud-plus/guide/questions.html" class="sidebar-link">常见问题</a></li><li><a href="/d2-crud-plus/guide/contact.html" class="sidebar-link">联系作者</a></li><li><a href="/d2-crud-plus/guide/donate.html" class="sidebar-link">捐赠</a></li><li><a href="/d2-crud-plus/guide/users.html" class="sidebar-link">他们在用</a></li></ul></section></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>ChangeLog</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/d2-crud-plus/guide/changelogs/packages/d2-crud-x/CHANGELOG.html" class="sidebar-link">d2-crud-x</a></li><li><a href="/d2-crud-plus/guide/changelogs/packages/d2-crud-plus/CHANGELOG.html" class="sidebar-link">d2-crud-plus</a></li><li><a href="/d2-crud-plus/guide/changelogs/packages/d2-crud-plus-extends/CHANGELOG.html" class="sidebar-link">d2-crud-plus-extends</a></li><li><a href="/d2-crud-plus/guide/changelogs/packages/d2-crud-plus-example/CHANGELOG.html" class="sidebar-link">d2-crud-plus-example</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="数据字典"><a href="#数据字典" class="header-anchor">#</a> 数据字典</h1> <p>配置数据字典之后， type=【select/area-selector/cascader/tree-selector/radio/dict-switch/checkbox】
这些字段类型就可以通过数据字典获取label及其选项，无需自己写各种各样乱七八糟的options</p> <h2 id="字典配置复制"><a href="#字典配置复制" class="header-anchor">#</a> 字典配置复制</h2> <div class="language-js extra-class"><pre class="language-js"><code>columns<span class="token punctuation">[</span>
  <span class="token punctuation">{</span> 
    dict<span class="token punctuation">:</span><span class="token punctuation">{</span><span class="token punctuation">}</span>  
  <span class="token punctuation">}</span>
<span class="token punctuation">]</span>
</code></pre></div><p>字段下配置dict会在页面初始化后复制到<code>search.component.props</code>、<code>form.component.props</code>、<code>component.props</code> 下<br>
如果需要search、form、component有不同的表现，直接配置对应位置的dict即可覆盖基本配置<br>
更多信息请先阅读:<a href="/d2-crud-plus/guide/mixins.html">核心逻辑</a></p> <h2 id="数据字典的配置"><a href="#数据字典的配置" class="header-anchor">#</a> 数据字典的配置</h2> <p>通常配置在column下,然后被分别赋值到component.dict和form.component.dict</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">export</span> <span class="token keyword">const</span> crudOptions <span class="token operator">=</span> <span class="token punctuation">{</span>
  columns<span class="token punctuation">:</span> <span class="token punctuation">[</span> <span class="token comment">//字段配置</span>
    <span class="token punctuation">{</span>
      dict<span class="token punctuation">:</span><span class="token punctuation">{</span>
        <span class="token comment">// 这里配置远程获取字典数据的请求地址</span>
        url<span class="token punctuation">:</span><span class="token string">'remote/dict/url'</span><span class="token punctuation">,</span> 
        <span class="token comment">// 或者配置一个方法，动态构建url</span>
        <span class="token function-variable function">url</span><span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token parameter">dict<span class="token punctuation">,</span><span class="token punctuation">{</span>form<span class="token punctuation">,</span>component<span class="token punctuation">}</span></span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span> 
          <span class="token keyword">return</span> <span class="token string">'newUrl'</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span> 
        data<span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token comment">//[Array]，如果数据无需远程获取，可以直接将字典数组写在这里</span>
           <span class="token punctuation">{</span>
            value<span class="token punctuation">:</span><span class="token number">1</span><span class="token punctuation">,</span>
            label<span class="token punctuation">:</span><span class="token string">'开启'</span><span class="token punctuation">,</span> 
            color<span class="token punctuation">:</span><span class="token string">'primary'</span><span class="token punctuation">,</span> <span class="token comment">//颜色 【primary，success，danger，warning，info】</span>
            disabled<span class="token punctuation">:</span><span class="token boolean">false</span> <span class="token comment">//是否禁用</span>
            <span class="token punctuation">}</span>
        <span class="token punctuation">]</span><span class="token punctuation">,</span> 
        <span class="token function-variable function">getData</span><span class="token punctuation">:</span><span class="token punctuation">(</span><span class="token parameter">url<span class="token punctuation">,</span>dict<span class="token punctuation">,</span><span class="token punctuation">{</span>form<span class="token punctuation">,</span>component<span class="token punctuation">}</span></span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span> <span class="token comment">//配置此参数会覆盖全局的getRemoteDictFunc</span>
          <span class="token keyword">return</span> <span class="token function">request</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token parameter">ret</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span><span class="token keyword">return</span> ret<span class="token punctuation">.</span>data<span class="token punctuation">}</span><span class="token punctuation">)</span>
        <span class="token punctuation">}</span><span class="token punctuation">,</span>
        cache<span class="token punctuation">:</span><span class="token boolean">true</span><span class="token punctuation">,</span> <span class="token comment">//默认开启缓存</span>
        value<span class="token punctuation">:</span> <span class="token string">'value'</span><span class="token punctuation">,</span> <span class="token comment">// 数据字典中value字段的属性名</span>
        label<span class="token punctuation">:</span> <span class="token string">'label'</span><span class="token punctuation">,</span> <span class="token comment">// 数据字典中label字段的属性名</span>
        children<span class="token punctuation">:</span> <span class="token string">'children'</span><span class="token punctuation">,</span> <span class="token comment">// 数据字典中children字段的属性名</span>
        isTree<span class="token punctuation">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span> <span class="token comment">// 此数据字典是否是树形的，通常用于级联组件、地区选择组件等处</span>
        clone<span class="token punctuation">:</span> <span class="token boolean">false</span><span class="token punctuation">,</span> <span class="token comment">// 是否在获取到字典数据之后clone一份,clone之后不影响全局缓存，可以随意修改</span>
        <span class="token function">getNodes</span><span class="token punctuation">(</span><span class="token parameter">values</span><span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token keyword">return</span> nodeArr<span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token comment">//根据value数组，返回节点数据，用于懒加载时，行展示组件的label显示</span>
        <span class="token function-variable function">transfer</span><span class="token punctuation">:</span><span class="token punctuation">(</span><span class="token parameter">data<span class="token punctuation">,</span>options</span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span><span class="token keyword">return</span> data<span class="token punctuation">}</span><span class="token punctuation">,</span><span class="token comment">// 可以修改获取到的远程数据，比如将字典的id字段转成字符串形式（缓存开启时只会执行一次）</span>
        <span class="token function">onReady</span><span class="token punctuation">(</span><span class="token parameter">data<span class="token punctuation">,</span> dict<span class="token punctuation">,</span> context</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
          <span class="token comment">//远程数据字典加载完成事件，每个引用该字典的组件都会触发一次</span>
        <span class="token punctuation">}</span>   
      <span class="token punctuation">}</span>   
    <span class="token punctuation">}</span>
<span class="token punctuation">]</span><span class="token punctuation">}</span>
</code></pre></div><p>注意：dict会以url作为缓存key，使得该字典只会远程获取一次。</p> <div class="language-js extra-class"><pre class="language-js"><code>dict<span class="token punctuation">:</span><span class="token punctuation">{</span>
    cache<span class="token punctuation">:</span><span class="token boolean">false</span> <span class="token comment">//可以禁用缓存</span>
<span class="token punctuation">}</span>
</code></pre></div><p>注意： <code>getData()</code> 会覆盖全局的getRemoteDictFunc</p> <ul><li><code>getData()</code> ：如果配置相同的url，即便getData不一样，还是会获取到相同的字典数据，可以通过url单独清理缓存</li></ul> <h2 id="页面中获取数据字典"><a href="#页面中获取数据字典" class="header-anchor">#</a> 页面中获取数据字典</h2> <div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getDictData</span><span class="token punctuation">(</span>dict<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token parameter">data</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>dictData <span class="token operator">=</span> data 
<span class="token punctuation">}</span><span class="token punctuation">)</span>

<span class="token comment">// 还可以传入列的key,根据该列的dict配置来获取字典数据</span>
<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getDictData</span><span class="token punctuation">(</span><span class="token string">'columnKey'</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token parameter">data</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>dictData <span class="token operator">=</span> data 
<span class="token punctuation">}</span><span class="token punctuation">)</span>

<span class="token comment">// 返回map</span>
<span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">getDictData</span><span class="token punctuation">(</span><span class="token string">'columnKey'</span><span class="token punctuation">,</span><span class="token punctuation">{</span>returnType<span class="token punctuation">:</span><span class="token string">'dataMap'</span><span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token parameter">dataMap</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>
  <span class="token keyword">this</span><span class="token punctuation">.</span>dictDataMap <span class="token operator">=</span> dataMap 
<span class="token punctuation">}</span><span class="token punctuation">)</span>
        
</code></pre></div><h2 id="清除字典缓存"><a href="#清除字典缓存" class="header-anchor">#</a> 清除字典缓存</h2> <p>远程字典会以url作为key缓存在内存里面<br>
某些情况下需要清空字典缓存，比如添加修改删除字典项的时候</p> <div class="language-javascript extra-class"><pre class="language-javascript"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> d2CrudPlus <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'d2-crud-plus'</span>
d2CrudPlus<span class="token punctuation">.</span>util<span class="token punctuation">.</span>dict<span class="token punctuation">.</span><span class="token function">clear</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">//清空所有字典缓存</span>
d2CrudPlus<span class="token punctuation">.</span>util<span class="token punctuation">.</span>dict<span class="token punctuation">.</span><span class="token function">clear</span><span class="token punctuation">(</span>url<span class="token punctuation">)</span> <span class="token comment">//清空单个字典缓存</span>
</code></pre></div><h2 id="onready事件监听"><a href="#onready事件监听" class="header-anchor">#</a> onReady事件监听</h2> <p>当dict获取到远程数据之后，会触发onReady事件</p> <div class="language-js extra-class"><pre class="language-js"><code>dict<span class="token punctuation">:</span><span class="token punctuation">{</span>
  <span class="token function-variable function">onReady</span><span class="token punctuation">:</span> <span class="token punctuation">(</span><span class="token parameter">data<span class="token punctuation">,</span> dict<span class="token punctuation">,</span><span class="token punctuation">{</span>form<span class="token punctuation">,</span>component<span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
      <span class="token keyword">let</span> value <span class="token operator">=</span> vm<span class="token punctuation">.</span><span class="token function">getEditForm</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span>checkbox
      <span class="token keyword">if</span> <span class="token punctuation">(</span>value <span class="token operator">==</span> <span class="token keyword">null</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        value <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token punctuation">]</span>
      <span class="token punctuation">}</span>
      <span class="token function">radioOptionsChanged</span><span class="token punctuation">(</span>vm<span class="token punctuation">,</span> value<span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="如何设置行展示组件【values-format】的颜色"><a href="#如何设置行展示组件【values-format】的颜色" class="header-anchor">#</a> 如何设置行展示组件【values-format】的颜色</h2> <p>方法1
获取的字典数据中，带上color即可，可选值【primary,success,danger,warning,info】
<code>data:[{value:xx,label:xx,color:'success'}]</code></p> <p>方法2
如果后台不方便返回color，可以给字段配置自动染色
<code>columns:[{component:{props:{color:'auto'}}}]</code></p> <p>方法3
或者手动设置</p> <div class="language-js extra-class"><pre class="language-js"><code>dict<span class="token punctuation">:</span><span class="token punctuation">{</span>
 <span class="token function-variable function">getData</span><span class="token punctuation">:</span><span class="token punctuation">(</span><span class="token parameter">url<span class="token punctuation">,</span>dict<span class="token punctuation">,</span><span class="token punctuation">{</span>form<span class="token punctuation">,</span>component<span class="token punctuation">}</span></span><span class="token punctuation">)</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span> <span class="token comment">//配置此参数会覆盖全局的getRemoteDictFunc</span>
          <span class="token keyword">return</span> <span class="token function">request</span><span class="token punctuation">(</span>url<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">then</span><span class="token punctuation">(</span><span class="token parameter">ret</span><span class="token operator">=&gt;</span><span class="token punctuation">{</span>
                    <span class="token comment">//修改颜色值</span>
                    <span class="token keyword">return</span> ret<span class="token punctuation">.</span>data
           <span class="token punctuation">}</span><span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre></div><h2 id="动态修改字典数据"><a href="#动态修改字典数据" class="header-anchor">#</a> 动态修改字典数据</h2> <p>直接修改dict.data无法动态修改select的选项数据</p> <p>方式1： 配置DictSelect组件的options(数据结构与dict.data一致)，options参数比dict.data具有更高优先级，并且可以动态修改</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token function">valueChange</span> <span class="token punctuation">(</span><span class="token parameter">key<span class="token punctuation">,</span> value<span class="token punctuation">,</span> form<span class="token punctuation">,</span> <span class="token punctuation">{</span> getColumn<span class="token punctuation">,</span> mode<span class="token punctuation">,</span> component<span class="token punctuation">,</span> immediate<span class="token punctuation">,</span> getComponent <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
       <span class="token function">getColumn</span><span class="token punctuation">(</span><span class="token string">'key'</span><span class="token punctuation">)</span><span class="token punctuation">.</span>component<span class="token punctuation">.</span>props<span class="token punctuation">.</span>options<span class="token operator">=</span><span class="token punctuation">[</span><span class="token punctuation">{</span>字典数据<span class="token punctuation">}</span><span class="token punctuation">]</span>
 <span class="token punctuation">}</span><span class="token punctuation">,</span>
</code></pre></div><p>方式2： 参考选择联动http://preview.d2-crud-plus.docmirror.cn/D2CrudPlusExample/index.html#/demo/form/linkage</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token function">valueChange</span> <span class="token punctuation">(</span><span class="token parameter">key<span class="token punctuation">,</span> value<span class="token punctuation">,</span> form<span class="token punctuation">,</span> <span class="token punctuation">{</span> getColumn<span class="token punctuation">,</span> mode<span class="token punctuation">,</span> component<span class="token punctuation">,</span> immediate<span class="token punctuation">,</span> getComponent <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
            form<span class="token punctuation">.</span>city <span class="token operator">=</span> <span class="token keyword">undefined</span> <span class="token comment">// 将“city”的值置空</span>
            form<span class="token punctuation">.</span>county <span class="token operator">=</span> <span class="token keyword">undefined</span><span class="token comment">// 将“county”的值置空</span>
            <span class="token keyword">if</span> <span class="token punctuation">(</span>value<span class="token punctuation">)</span> <span class="token punctuation">{</span>
              <span class="token function">getComponent</span><span class="token punctuation">(</span><span class="token string">'city'</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">reloadDict</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">// 执行city的select组件的reloadDict()方法，触发“city”重新加载字典</span>
            <span class="token punctuation">}</span>
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
</code></pre></div><p>DictSelect、DictRadio、DictCheckbox组件ref暴露如下一些方法可以操作字典：</p> <div class="language-js extra-class"><pre class="language-js"><code>component<span class="token punctuation">.</span><span class="token function">clearDict</span><span class="token punctuation">(</span><span class="token punctuation">)</span>  <span class="token comment">//清除字典</span>
component<span class="token punctuation">.</span><span class="token function">loadDict</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token comment">//加载字典</span>
component<span class="token punctuation">.</span><span class="token function">setDictData</span><span class="token punctuation">(</span>data<span class="token punctuation">)</span> <span class="token comment">//修改字典数据</span>
component<span class="token punctuation">.</span><span class="token function">getDictData</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
</code></pre></div><p>方式3：动态修改dict.url 也会触发字典重载</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token function">valueChange</span> <span class="token punctuation">(</span><span class="token parameter">key<span class="token punctuation">,</span> value<span class="token punctuation">,</span> form<span class="token punctuation">,</span> <span class="token punctuation">{</span> getColumn<span class="token punctuation">,</span> mode<span class="token punctuation">,</span> component<span class="token punctuation">,</span> immediate<span class="token punctuation">,</span> getComponent <span class="token punctuation">}</span></span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
       <span class="token function">getColumn</span><span class="token punctuation">(</span><span class="token string">'key'</span><span class="token punctuation">)</span><span class="token punctuation">.</span>component<span class="token punctuation">.</span>props<span class="token punctuation">.</span>dict<span class="token punctuation">.</span>url<span class="token operator">=</span>dict<span class="token punctuation">.</span>url<span class="token operator">?</span>params<span class="token operator">=</span>xxx <span class="token comment">//不同的参数获取不同的字典列表</span>
 <span class="token punctuation">}</span><span class="token punctuation">,</span>

</code></pre></div><h2 id="字典缓存仅页面级别生效"><a href="#字典缓存仅页面级别生效" class="header-anchor">#</a> 字典缓存仅页面级别生效</h2> <p>在页面的created方法中清空所有字典缓存即可</p> <div class="language-js extra-class"><pre class="language-js"><code><span class="token keyword">import</span> <span class="token punctuation">{</span> d2CrudPlus <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">'d2-crud-plus'</span>
<span class="token keyword">export</span> <span class="token keyword">const</span> crudOptions<span class="token operator">=</span> <span class="token punctuation">{</span>
 pageOptions<span class="token punctuation">:</span><span class="token punctuation">{</span>
    <span class="token function">onInitAfter</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span> <span class="token comment">//初始化完成后，清空所有字典缓存</span>
        d2CrudPlus<span class="token punctuation">.</span>util<span class="token punctuation">.</span>dict<span class="token punctuation">.</span><span class="token function">clear</span><span class="token punctuation">(</span><span class="token punctuation">)</span> 
    <span class="token punctuation">}</span>
 <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/greper/d2-crud-plus/edit/master//docs/guide/dict.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">2022/1/5 下午4:51:55</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/d2-crud-plus/guide/extends.html" class="prev">
        自定义扩展
      </a></span> <span class="next"><a href="/d2-crud-plus/guide/nest-data.html">
        多级数据
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"></div></div>
    <script src="/d2-crud-plus/assets/js/app.cf559687.js" defer></script><script src="/d2-crud-plus/assets/js/2.40e3d83c.js" defer></script><script src="/d2-crud-plus/assets/js/7.20165752.js" defer></script><script src="/d2-crud-plus/assets/js/73.4c7255c5.js" defer></script>
  </body>
</html>
